package com.gedi.data.InputFormate.DBInputFormate;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author:RenPu
 * @Date: 2020/1/13 11:52
 * @Version: 1.0
 * @description:
 */
public class OrderMapper extends Mapper<LongWritable,OrderWritable, Text, DoubleWritable> {


    @Override
    protected void map(LongWritable key, OrderWritable value, Context context) throws IOException, InterruptedException {

        Date createTime = value.getCreateTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
        String format = simpleDateFormat.format(createTime);
        System.out.println(format+"------------------------------------------");
        Double totalMoney = value.getTotalMoney();
        Integer userId = value.getUserId();
        String month=format+userId;
        context.write(new Text(month),new DoubleWritable(totalMoney));
    }

}
